package com.gjy.learning.scala.util

import org.apache.spark.sql.DataFrame

trait GetHeadOption {
  def getFirstString(df: DataFrame): String = {
    df.take(1).headOption.map(_.getString(0)).getOrElse("")
  }

  def getHeadOption(df: DataFrame): Any = {
    df.take(1).headOption.map(_.get(0)).getOrElse(null.asInstanceOf[Any])
  }
}
